home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / guibuilder / GenATalk.template next >
Encoding:
Text File  |  2004-01-31  |  5.1 KB  |  209 lines

  1. "****h* $ProjectFileName [$ProjectVersion] ************************ "
  2. "*"
  3. "* NAME"
  4. "*    $ProjectFileName"
  5. "*"
  6. "* DESCRIPTION"
  7. "*    $ProjectNameGUI Class is a GUI for...."
  8. "*"
  9. "* HISTORY"
  10. "*    $DateToday - Created this file."
  11. "*"
  12. "* COPYRIGHT"
  13. "*    $ProjectFileName $DateToday(C) by $ProjectAuthorName"
  14. "*"
  15. "* NOTES"
  16. "*    This Template is NOT complete or Tested!!                                 "
  17. "*    $VER: $ProjectFileName $ProjectVersion ($DateToday) by $ProjectAuthorName "
  18. "************************************************************************"
  19.  
  20. Class $ProjectNameGUI :Window  " Controller "
  21. !
  22.   intuition  screen    viObj       guiWindow 
  23.   scrFont    fontAttr  wTags       ctrlDictionary
  24.   gadgetList menuStrip firstGadget itexts bboxes 
  25. !
  26. [
  27.    startUp
  28.       self controlInitialize.
  29.       self controlLoop.
  30.       self controlTerminate
  31. |
  32.    terminateAndInitializeAround: aBlock
  33.       self controlTerminate.
  34.  
  35.       aBlock value.
  36.  
  37.       self controlInitialize
  38. |
  39.    controlLoop ! notDone userData !
  40.  
  41.       " Sent by startUp as part of the standard control sequence. 
  42.       * As long as true is returned, the loop continues. 
  43.       * When false is returned, the loop ends:
  44.       "
  45.       notDone <- true.
  46.       
  47.       [notDone = true]
  48.         whileTrue: [ " userData is an Array Object with at least 2 elements: "
  49.                      userData <- self waitForUserData.
  50.  
  51.                      notDone  <- self decode: userData.
  52.                    ].
  53.  
  54.       ^ false  " Inform everyone that we are done "
  55. |
  56.    controlTerminate   ! ele controlObj !
  57.       
  58.       " User did something to exit the Controller Loop.
  59.       * Provide a place in the standard control sequence for terminating the 
  60.       * receiver (taking into account the current state of its model and view).
  61.       "
  62.       
  63.       ele <- ctrlDictionary first.
  64.       
  65.       [ele notNil]
  66.          whileTrue: [ controlObj <- ctrlDictionary at: ele.
  67.                       
  68.                       controlObj dispose.
  69.                                              
  70.                       ctrlDictionary removeKey: ele ifAbsent: [].
  71.  
  72.                       ele <- ctrlDictionary next. 
  73.                     ].
  74.       self close.
  75.       
  76.       ^ nil
  77. |
  78.    tieInto: thisView
  79.       guiWindow <- thisView window
  80. |
  81.    addControl: controlObject named: ctrlID
  82.       ctrlDictionary at: ctrlID put: controlObject.
  83.  
  84.       controlObject registerTo: guiWindow
  85. |
  86.    addHotKey: keyValue to: controlObject
  87.       " Upper-case & lower-case keys are equivalent here: " 
  88.       <primitive 239 3 12 keyValue controlObject>
  89. |
  90.    addMenuSelection: menuObject named: menuID
  91.       ctrlDictionary at: menuID put: menuObject
  92.  
  93.       menuObject registerTo: guiWindow
  94. |
  95.    addMenuHotKey: keyValue to: menuObject
  96.       <primitive 239 1 12 keyValue menuObject>
  97. |
  98.    waitForUserData
  99.       " userData is an Array of three elements, first is the 
  100.       * Gadget (controlObject) value, second is the userData 
  101.       * (a #methodSymbol for this Class), third is the hotKey value.
  102.       *
  103.       * If the User selected a menu item, the first element is
  104.       * the menuitem userData, second is the menuitem Label, 
  105.       * third is Command Key equivalent (a through z, 0 through 9, 
  106.       * or A through Z only [for now!]) 
  107.       "
  108.       ^ <primitive 239 3 9 guiWindow>
  109. |
  110.    closeGUIWindow
  111.       self close.
  112.       
  113.       ^ false
  114. |
  115.    rawKey: keyCode
  116.       ^ true
  117. |
  118.    vanillaKey: keyCode
  119.       ^ true
  120. |
  121.    newSizeWindow
  122.       ^ true
  123. |
  124.    changeWindow
  125.       ^ true
  126. |
  127.    decode: controlData ! ctrlValue ctrlID hotKey !
  128.       ctrlValue <- controlData at: 1. " Usuallly a Symbol  "
  129.       ctrlID    <- controlData at: 2. " String or Integer  "
  130.       hotKey    <- controlData at: 3. " raw or vanilla key "
  131.       
  132.       (ctrlValue = #closeWindow)
  133.          ifTrue: [ ^ self closeGUIWindow ].
  134.          
  135.       (ctrlValue = #rawKey)
  136.          ifTrue: [ ^ self rawKey: hotKey ].
  137.                   
  138.       (ctrlValue = #vanillaKey)
  139.          ifTrue: [ ^ self vanillaKey: hotKey ].
  140.                   
  141.       (ctrlValue = #newSizeWindow)
  142.          ifTrue: [ ^ self newSizeWindow ].
  143.                   
  144.       (ctrlValue = #changeWindow)
  145.          ifTrue: [ ^ self changeWindow ].
  146.                   
  147.       ^ (ctrlDictionary at: ctrlID) perform: ctrlValue
  148. |
  149.    controlInitialize
  150.       " super initialize. "
  151.  
  152.       intuition <- Intuition new.
  153.       
  154.       self setupIntuiTexts.
  155.       self setupBevelBoxes.
  156.              
  157.       $SetupScreenCode
  158.  
  159.       firstGadget <- self setupGadgets.
  160.  
  161.       self setupMenuStrip.
  162.        
  163.       $OpenWindowCode
  164.       
  165.       self renderIntuiTexts.
  166.       
  167.       self renderBevelBoxes.
  168. |
  169.    setupIntuiTexts
  170.       $SetupIntuiTexts
  171. |
  172.    setupBevelBoxes
  173.       $SetupBevelBoxes
  174. |
  175.    setupGadgets ! gadget !
  176.  
  177.       $SetupGadgets
  178.       
  179.       ^ gadgetList
  180. |
  181.    setupMenuStrip
  182.       $SetupMenus ==>>
  183.  
  184.       menuStrip <- MenuStrip new: $MenuCount.
  185.       
  186.       ^ menuStrip 
  187. |
  188. $RenderIntuiTexts
  189. |
  190. $RenderBevelBoxes
  191. |
  192.    close
  193.       " CloseWindowCode: "
  194.  
  195.       guiWindow close.
  196.  
  197.       $DisposeGadgets
  198.       $DisposeMenus
  199.       $DisposeITexts
  200.       $DisposeBBoxes
  201.             
  202.       " CloseScreenCode: "
  203.       
  204.       screen disposeVisualInfo: viObj.
  205.       
  206.       screen  close.
  207.       scrFont close.
  208. ]
  209.